package com.zlsx.androidutil.androidview.pickcolorview;

import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.zlsx.androidutil.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ColorPickActivity extends AppCompatActivity {
    @BindView(R.id.color_rgb)
    TextView colorRgb;
    @BindView(R.id.cpv)
    ColorPickerView cpv;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_color_picker);
        ButterKnife.bind(this);
        cpv.setOnColorChangedListenner(new OnColorChangedLisener() {
            @Override
            public void onColorChanged(int r, int g, int b) {
                if (r == 0 && g == 0 && b == 0) {
                    return;
                }
                colorRgb.setText(String.format(getString(R.string.TEXT_RGB), r, g, b));
            }

            @Override
            public void onMoveColor(int r, int g, int b) {
                if (r == 0 && g == 0 && b == 0) {
                    return;
                }
                colorRgb.setText(String.format(getString(R.string.TEXT_RGB), r, g, b));
            }
        });
    }
}